﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WebNetCorePhoneErp.IBLL;
using WebNetCorePhoneErp.IDAL;
using WebNetCorePhoneErp.Model;

namespace WebNetCorePhoneErp.BLL
{
    /// <summary>
    /// 品牌-业务实现
    /// </summary>
    public class BrandBusinessImpl : IBrandBusiness
    {
        private IBrandDAL brandDAL;
        private IOperate_logDAL operate_LogDAL;

        public BrandBusinessImpl(IBrandDAL _brandDAL, IOperate_logDAL _operate_LogDAL)
        {
            brandDAL = _brandDAL;
            operate_LogDAL = _operate_LogDAL;
        }

        public async Task<Result> AddBrandAsync(Brand brand, UserView userView)
        {
            if (brand == null)
            {
                return new Result("brand不可为空");
            }
            if (string.IsNullOrWhiteSpace(brand.Brand_name))
            {
                return new Result("Brand_name不可为空");
            }
            int count = await brandDAL.AddAsync(brand);
            if (count > 0)
            {
                //操作日志记录
                //operate_LogDAL.AddAsync();
                return new Result(true);
            }
            return new Result("保存失败");
        }

        public async Task<Result> UpdateBrandAsync(Brand brand, UserView userView)
        {
            throw new NotImplementedException();
        }

        public async Task<Result> UpdateStateBrandAsync(string id, UserView userView)
        {
            throw new NotImplementedException();
        }
    }
}
